// TypeScript file
module Fighter {

    /**
     * 获胜Ui——郭启航
     */
    export class WinUI extends eui.Component {

        constructor() {
            super();
            this.skinName = "resource/assets/PlaneE/Win.exml";
            this.addEventListener(egret.Event.ADDED_TO_STAGE, this.AddToStage, this);
           // this.addEventListener(egret.Event.ENTER_FRAME, this.show, this);
        }
        public Tips: eui.Label;
        /**胜利返回按钮*/
        public Win_BackPage: eui.Image;
        /**重新开始 */
        public is_restart: boolean = false;
        public AddToStage() {
            this.Tips.visible=false;
            this.Win_BackPage.addEventListener(egret.TouchEvent.TOUCH_TAP, this.Close, this);
            if (!GameUtil.PlayerMessage.instance.onePerson) {
                this.sendMsg();
            }
             if (GameUtil.PlayerMessage.instance.isLeave) {
                this.Tips.visible = true;
                console.log("对方断线");
            }
            else{
                this.Tips.visible = false;
            }
        }
      
        /**每帧显示 是否掉线*/
        public show() {
           
        }
        public Close(evt: egret.TouchEvent) {
            if (GameUtil.PlayerMessage.instance.onePerson == false && Fighter.OlUI.OlUI_solo.is_match == false) {
                this.Win_BackPage.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.Close, this);
            }
            GameUtil.PlayerMessage.instance.isGameOver = true;
            GameUtil.PlayerMessage.instance.isBuyAroundPlane = false;
            GameUtil.PlayerMessage.instance.isBuyFollowPlane = false;
            this.is_restart = true;
        }
        /**向开放数据域通信 */
        private sendMsg() {
            let platform: any = window.platform;
            platform.openDataContext.postMessage({
                win: "1",
                lose: "0"
            });
        }
    }
}